
package tile;

import java.io.File;
import java.util.Iterator;
import java.util.List;
import org.thereconstruction.tileset.Tiles;
import org.thereconstruction.tileset.Tiles.Tile;

/**
 *  Verification for Tilesets
 * @author Sebastian Audet
 */
public class TilesetVerification {
    public static boolean isCorrect(File tileset) {
        XMLTileSet tset = new XMLTileSet(tileset);
        Iterator itr = tset.tiles.getTile().iterator();
        while(itr.hasNext()) {
            Tiles.Tile t = (Tile) itr.next();
            if(!(new File("tile/"+t.getFile()).exists())) {
                return false;
            }
        }
        return true;
    }
    
    public static void pl(Object string) {
        System.out.println(string);
    }
    
    public static void printExistence(File tileset) {
        XMLTileSet tset = new XMLTileSet(tileset);
        Iterator itr = tset.tiles.getTile().iterator();
        while(itr.hasNext()) {
            Tiles.Tile t = (Tile) itr.next();
            if(!(new File("tile/"+t.getFile()).exists())) {
                pl(t.getFile()+" is bad");
            } else {
            pl(t.getFile()+" is good"); }
        }
    }
    
    public static void main(String[] args) {
        File file = new File("tile/TintTiles.xml");
        pl(file.exists());
        pl(isCorrect(file));
        printExistence(file);
        file = new File("tile/MyTileSet.xml");
        pl(file.exists());
        pl(isCorrect(file));
        printExistence(file);
        file = new File("tile/People.xml");
        pl(file.exists());
        pl(isCorrect(file));
        printExistence(file);
    }
    
    /*public static boolean isCorrect(Class<? extends TileSet> tileset) {
        tileset.asSubclass(AbstractTileSet.class);
        throw new UnsupportedFeatureException("Not yet implemented");
        return true;
    }*/
}
